using UnityEngine;
using System.Collections;

public class PanningString : MonoBehaviour{
	
	//. main data
	private string strPan;
	private Vector3 BeforeVec3;
	public PanningString()
	{
		BeforeVec3 = Vector3.zero;
	}
	
	public string GetString
	{
		//. Action over -> return String
		get { 
			return this.strPan; 
		}
	}
	public bool ClearString()
	{
		try
		{
			//. Remove all data
			strPan.Remove(0);
			return true;
		}
		catch
		{
			return false;
		}
	}
	public bool AddPanningPosition(Vector3 _vec3)
	{
		//. try added vector to string in strPan.
		try
		{
			if( Vector3.Distance(BeforeVec3,_vec3 ) < 0.5f )
			{
//				print("In <0.5f ");
				return true;
			}
			else if( Vector3.Distance(BeforeVec3,_vec3) > 1.0f )
			{
//				print("In > 1.0f");
				BeforeVec3 = (BeforeVec3 + _vec3)/2;
				 strPan +=	BeforeVec3.x.ToString() +
				 	"," +	BeforeVec3.y.ToString() +
				 	"," +	BeforeVec3.z.ToString() +
					"$";
//				print("before vec3 : "+BeforeVec3);
			}
			BeforeVec3 = _vec3;
			
			 strPan +=	_vec3.x.ToString() +
			 	"," +	_vec3.y.ToString() +
			 	"," +	_vec3.z.ToString() +
				"$";
			return true;
		}
		catch
		{
			return false;
		}
	}
	
	
	
}
